package org.cancer.common

import org.apache.spark.SparkConf
import org.apache.spark.sql.SparkSession
import org.apache.spark.streaming.Seconds
import org.cancer.util.SparkUtil

trait TApp_Faye extends App {
  var spark: SparkSession = _

  def start(master: String = "local[*]", appName: String = "Application")(op: => Unit): Unit = {
    val sparkConf = new SparkConf().setMaster(master).setAppName(appName)
    val sc = SparkUtil.CreateSpark(sparkConf, Seconds(10))
    spark = SparkUtil.takeSpark()
    val ssc = SparkUtil.takeSSC()

    // 添加检查点目录
    ssc.checkpoint("output/checkpoint/CancerTypeDeath")

    sc.setLogLevel("ERROR")
    try {
      op
    } catch {
      case ex => ex.printStackTrace()
    }
  }
}
